﻿<template>
	<div class="projectResult-container">
		<el-dialog v-model="isShowDialog" :width="800" draggable="" @close="cancel">
			<template #header>
				<div style="color: #fff">
					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
					<span>{{ props.title }}</span>
				</div>
			</template>
			<el-form :model="ruleForm" ref="ruleFormRef" label-width="auto" :rules="rules">
				<el-row :gutter="35">
					<el-form-item v-show="false">
						<el-input v-model="ruleForm.id" />
					</el-form-item>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.projectNo')" prop="projectNo">
							<el-input v-model="ruleForm.projectNo" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.projectNo')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.gCode')" prop="gCode">
							<el-input v-model="ruleForm.gCode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.gCode')" maxlength="255" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.deviceList')" prop="deviceList">
							<el-input v-model="ruleForm.deviceList" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.deviceList')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.vMPathNew')" prop="vMPathNew">
							<el-input v-model="ruleForm.vMPathNew" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.vMPathNew')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.cADPathNew')" prop="cADPathNew">
							<el-input v-model="ruleForm.cADPathNew" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.cADPathNew')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.efficiency')" prop="efficiency">
							<el-input v-model="ruleForm.efficiency" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.efficiency')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.robotModel')" prop="robotModel">
							<el-input v-model="ruleForm.robotModel" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.robotModel')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.robotQty')" prop="robotQty">
							<el-input v-model="ruleForm.robotQty" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.robotQty')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.blanketMode')" prop="blanketMode">
							<el-input v-model="ruleForm.blanketMode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.blanketMode')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.binType')" prop="binType">
							<el-input v-model="ruleForm.binType" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.binType')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.binSize')" prop="binSize">
							<el-input v-model="ruleForm.binSize" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.binSize')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.chargeQty')" prop="chargeQty">
							<el-input-number v-model="ruleForm.chargeQty" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.chargeQty')" clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.binQty')" prop="binQty">
							<el-input-number v-model="ruleForm.binQty" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.binQty')" clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.packQty')" prop="packQty">
							<el-input-number v-model="ruleForm.packQty" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.packQty')" clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.length')" prop="length">
							<el-input v-model="ruleForm.length" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.length')" maxlength="18" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.width')" prop="width">
							<el-input v-model="ruleForm.width" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.width')" maxlength="18" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.robotCode')" prop="robotCode">
							<el-input v-model="ruleForm.robotCode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.robotCode')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.blanketCode')" prop="blanketCode">
							<el-input v-model="ruleForm.blanketCode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.blanketCode')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.binTypeCode')" prop="binTypeCode">
							<el-input v-model="ruleForm.binTypeCode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.binTypeCode')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.chargeCode')" prop="chargeCode">
							<el-input v-model="ruleForm.chargeCode" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.chargeCode')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
						<el-form-item :label="$t('message.projectResult.totalPrice')" prop="totalPrice">
							<el-input v-model="ruleForm.totalPrice" :placeholder="$t('message.pageConfiguration.noticeinput')+ ' '+$t('message.projectResult.totalPrice')" maxlength="200" show-word-limit clearable />
							
						</el-form-item>
						
					</el-col>
				</el-row>
			</el-form>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="cancel">{{ $t('message.pageConfiguration.cancel') }}</el-button>
					<el-button type="primary" @click="submit">{{ $t('message.pageConfiguration.confirm') }}</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>
<style scoped>
:deep(.el-select),
:deep(.el-input-number) {
	width: 100%;
}
</style>
<script lang="ts" setup>
	import { ref,onMounted } from "vue";
	import { ElMessage } from "element-plus";
	import type { FormRules } from "element-plus";
	import { addProjectResult, updateProjectResult } from "/@/api/main/projectResult";

	import { useI18n } from 'vue-i18n';
	const { t ,locale} = useI18n();
	//父级传递来的参数
	var props = defineProps({
		title: {
		type: String,
		default: "",
	},
	});
	//父级传递来的函数，用于回调
	const emit = defineEmits(["updateData"]);
	const ruleFormRef = ref();
	const isShowDialog = ref(false);
	const ruleForm = ref<any>({});
	//自行添加其他规则
	const rules = ref<FormRules>({
		projectNo: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.projectNo'), trigger: 'blur',},],
		gCode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.gCode'), trigger: 'blur',},],
		deviceList: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.deviceList'), trigger: 'blur',},],
		vMPathNew: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.vMPathNew'), trigger: 'blur',},],
		cADPathNew: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.cADPathNew'), trigger: 'blur',},],
		efficiency: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.efficiency'), trigger: 'blur',},],
		robotModel: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.robotModel'), trigger: 'blur',},],
		robotQty: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.robotQty'), trigger: 'blur',},],
		blanketMode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.blanketMode'), trigger: 'blur',},],
		binType: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.binType'), trigger: 'blur',},],
		binSize: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.binSize'), trigger: 'blur',},],
		chargeQty: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.chargeQty'), trigger: 'blur',},],
		binQty: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.binQty'), trigger: 'blur',},],
		packQty: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.packQty'), trigger: 'blur',},],
		length: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.length'), trigger: 'blur',},],
		width: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.width'), trigger: 'blur',},],
		robotCode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.robotCode'), trigger: 'blur',},],
		blanketCode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.blanketCode'), trigger: 'blur',},],
		binTypeCode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.binTypeCode'), trigger: 'blur',},],
		chargeCode: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.chargeCode'), trigger: 'blur',},],
		totalPrice: [{required: true, message: t('message.pageConfiguration.noticeinput')+ ' '+t('message.projectResult.totalPrice'), trigger: 'blur',},],
	});

	// 打开弹窗
	const openDialog = (row: any) => {
		ruleForm.value = JSON.parse(JSON.stringify(row));
		isShowDialog.value = true;
	};

	// 关闭弹窗
	const closeDialog = () => {
		emit("updateData");
		isShowDialog.value = false;
	};

	// 取消
	const cancel = () => {
		isShowDialog.value = false;
	};

	// 提交
	const submit = async () => {
		ruleFormRef.value.validate(async (isValid: boolean, fields?: any) => {
			if (isValid) {
				let values = ruleForm.value;
				if (ruleForm.value.id == undefined || ruleForm.value.id == null || ruleForm.value.id == "" || ruleForm.value.id == 0) {
					await addProjectResult(values);
				} else {
					await updateProjectResult(values);
				}
				closeDialog();
			} else {
				ElMessage({
					message: `表单有${Object.keys(fields).length}处验证失败，请修改后再提交`,
					type: "error",
				});
			}
		});
	};







	// 页面加载时
	onMounted(async () => {
	});

	//将属性或者函数暴露给父组件
	defineExpose({ openDialog });
</script>




